package erfgame.core;

import java.awt.Point;
import java.io.Serializable;

@SuppressWarnings("serial")
public class Point3D extends Point implements Serializable {
	
	public int z;
	
	public Point3D() {
	}
	
	public Point3D( Point3D p )
	{
		this( p.x, p.y, p.z );
	}
	
	public Point3D( int x, int y, int z ) {
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public void setX(int x) {
		this.x = x;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getZ() {
		return z;
	}

	public void setZ(int z) {
		this.z = z;
	}
	
	public void rotate( Rotation rotation, Point around ) {
		rotate( rotation, around, new Point() );
	}
	
	public void rotate( Rotation rotation, Point around, Point tempPoint ) {
		tempPoint = rotation.rotate(this.x, this.y, around, tempPoint );
		this.x = tempPoint.x;
		this.y = tempPoint.y;
	}
	
	@Override
	public int hashCode() {
		return x<<8 + y<<20 + z;
	}
	
	@Override
	public boolean equals( Object o ) {
		if( o != null && o.getClass().equals( this.getClass() ) ) {
			return equals( (Point3D)o );
		} else {
			return false;
		}
	}
	
	public boolean equals( Point3D p ) {
		return p != null && p.x == this.x && p.y == this.y && p.z == this.z;
	}
	
	@Override
	public String toString() {
		return "("+x+","+y+","+z+")";
	}
	
	public static final class Double {
		public double x;
		public double y;
		public double z;
		
		public String toString() {
			return "("+x+","+y+","+z+")";
		}
	}
	
}
